package com.viknix.threadpool.manager.cluster.util;

import com.viknix.threadpool.manager.cluster.config.AuthConfigs;
import com.viknix.threadpool.manager.http.Header;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author: Dongqi
 * @Date: 2021/11/18 10:12
 * @Version 1.0
 * @Description: Auth header util.
 */
public class AuthHeaderUtil {

    /**
     * 将身份信息添加到 Http 头。
     *
     * @param header http header
     */
    public static void addIdentityToHeader(Header header) {
        AuthConfigs authConfigs = ApplicationUtils.getBean(AuthConfigs.class);
        if (StringUtils.isNotBlank(authConfigs.getServerIdentityKey())) {
            header.addParam(authConfigs.getServerIdentityKey(), authConfigs.getServerIdentityValue());
        }
    }

}
